#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>

#include <QFontDatabase>
#include <iostream>
#include <QThread>
#include <memory>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <QApplication>
#include <QQuickView>
#include "widget.h"
#include <QQmlComponent>
#include <QQuickItem>

int main(int argc, char *argv[])
{
    printCurrentThreadId();
 //   QGuiApplication app(argc, argv);
    QApplication app(argc, argv);

    qSetMessagePattern("[HMI]%{file}(%{line}): %{message}");

    QQmlApplicationEngine engine;


    engine.rootContext()->setContextProperty("menuObject", MenuObject::get());

    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
#if 0
    QList<QObject*> list = engine.rootObjects();
    QObject *obj = list.first();
    if(obj)
    {
        //MenuObject::get()->show();
    }
#endif
    return app.exec();
}
